package com.sword.ttserver;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ThreadTest {

	public static void main(String[] args) {
		long begin =System.currentTimeMillis();
		// 创建进程池
        int intCoreSize = 10;        
        ThreadPoolExecutor threadPool = new ThreadPoolExecutor(
                intCoreSize,
                intCoreSize, 3, TimeUnit.SECONDS,
                new LinkedBlockingQueue<Runnable>(),
                new ThreadPoolExecutor.CallerRunsPolicy());
        for(int i=0;i<10;i++){
        	OneThread one=new OneThread(i+"",i);
        	threadPool.execute(one);
        }
        
        long end =System.currentTimeMillis();
        System.out.println("end - begin:"+(end-begin));
	}	
}
